<template>
  <div class="contarner-page" @click.stop="showLanguageHandel">
    <page-header ref="languageRef"></page-header>
    <main>
      <div class="downloader flex_ccenter" v-if="!success">
        <div class="container">
          <div class="banner-heading flex_ccenter">
            <div class="heading-item">
              <h1 class="title fw700 f-42 c-fff">Unduh Cerita Instagram</h1>
              <h2 class="sub c-fff f-18 fw400">
                Pengunduh Cerita Instagram Terbaik Gratis
              </h2>
            </div>
          </div>
          <div class="form flex_center">
            <div class="input-box flex_between">
              <!-- <input
                    type="text"
                    class="input f-18"
                    v-model="input"
                    @input="handleInput"
                    @paste="handleInput"
                    placeholder="Paste URL Instagram"
                    list="fruits"
                    name="fruit"
                  />
                  <datalist id="fruits">
                    <option value="Apple"></option>
                    <option value="Banana"></option>
                    <option value="Cherry"></option>
                  </datalist> -->
              <input
                type="text"
                class="input f-18"
                v-model="input"
                :disabled="isHttpLoading"
                @input="handleInput"
                @paste="handleInput"
                @keydown="sendDownload($event)"
                placeholder="Paste URL Instagram"
              />
              <div
                class="Paste shou flex_center"
                @click="handleClickPasted"
                v-if="input == ''"
              >
                <div class="btnbg"></div>
                <div class="f-16 c-000 fw700">Paste</div>
              </div>
              <div
                class="clear shou flex_center"
                v-if="input != '' && !isHttpLoading"
                @click.stop="input = ''"
              >
                <div class="btnbg"></div>
                <div class="f-16 c-000 fw700">Clear</div>
              </div>
            </div>
            <div
              v-if="!isHttpLoading"
              @click.stop="downloadHandel"
              class="submit shou fw700 c-fff flex_center"
            >
              Download
            </div>
            <div v-else class="submit shou fw700 c-fff flex_center">
              Please wait
            </div>
          </div>
          <div class="app-submit flex_ccenter">
            <div
              class="submit flex_center"
              v-if="!isHttpLoading"
              @click.stop="downloadHandel"
            >
              <div class="fw700 c-fff f-21">Download</div>
            </div>
            <div class="submit flex_center" v-else>
              <div class="fw700 c-fff f-21">Please wait</div>
            </div>
          </div>
          <div class="loading" v-if="isHttpLoading">
            <div class="loading-dots flex_center">
              <div class="dot"></div>
              <div class="dot"></div>
              <div class="dot"></div>
              <div class="dot"></div>
            </div>
            <div class="tips f-18 flex_center">
              <div>Mengambil data, harap tunggu beberapa detik!</div>
            </div>
          </div>
          <div class="error flex_ccenter" v-if="httpError1">
            <div class="hono flex_">
              <div class="error-img"></div>
              <div class="error-img"></div>
              <div class="error-img"></div>
            </div>
            <div class="errMsg f-18">
              Situs tidak dapat memproses tautan Anda karena bersifat pribadi
            </div>
          </div>
          <div class="error flex_ccenter" v-if="httpError2">
            <div class="hono flex_">
              <div class="error-img"></div>
              <div class="error-img"></div>
              <div class="error-img"></div>
            </div>
            <div class="errMsg f-18">
              Data yang Anda masukkan bukan link, harap masukkan link yang valid
              contoh:
              <div>https://www.instagram.com/reel/Cml9qu-ISqx</div>
            </div>
          </div>
        </div>
      </div>
      <!-- 广告位start -->
      <!-- 广告位end -->
      <div class="container" v-if="!success">
        <div class="body-content">
          <div class="app-box">
            <div class="app-box__info">
              <h3 class="app-box__title f-21 fw700 c-000">
                Unduh dengan aplikasi Insta Downloader
              </h3>
              <p class="f-16 c-ccc">
                Aplikasi kami menawarkan solusi cepat dan sederhana untuk mengunduh
                 Video Instagram, menyediakan video berkualitas HD tanpa
                 tanda air.
              </p>
            </div>
            <div class="app-link">
              <a 
                  target="_blank" href="https://play.google.com/store/apps/details?id=ins.freevideodownload.pro">
                <img src="/static/images/google-play.webp" alt="Download app " />
              </a>
              <a href="https://apps.apple.com/us/app/repost-for-video-save-story/id6462401460"  target="_blank">
                <img src="/static/images/IOS.webp" alt="Download app " />
              </a>
            </div>
          </div>
          <div class="quick-info">
            <h3 class="f-32 c-000">
              Unduh Kisah Instagram dengan Savinginsta
            </h3>
            <p class="f-16 c-ccc">
              Savinginsta.Com adalah pengunduh cerita Instagram utama yang dikenal
               untuk kemudahan penggunaan dan kemampuan mengunduh Instagram berkualitas tinggi
               cerita dengan kecepatan tercepat. Unduh Cerita Instagram ke Anda
               ponsel, PC, atau tablet dengan kualitas terbaik menggunakan Instagram kami
               pengunduh video langsung dari browser Anda. Tidak ada perangkat lunak
               instalasi diperlukan, dan mendukung Android dan iOS.
            </p>
          </div>
          <div class="quick-info">
            <h3 class="f-32 c-000">
              Mengapa Menggunakan Savinginsta untuk Download Instagram Story?
            </h3>
            <p class="f-16 c-ccc">
              Instagram Stories yang berisi foto dan video menawan
               merupakan bagian penting dari ekspresi digital kita namun hanya terlihat
               selama 24 jam. Jika Anda suka melihat Instagram Stories dan ingin
               unduh, Savinginsta siap membantu. Cukup masukkan
               URL Instagram Story ke dalam Savinginsta, dan unduh yang terbaik
               Cerita Instagram gratis.
            </p>
          </div>
          <div class="how">
            <div class="how-title">
              <h3 class="f-36 c-000 italic">
                Bagaimana Cara Mengunduh Video Kisah Instagram?
              </h3>
            </div>
            <div class="steps">
              <div class="step">
                <div class="one">
                  <span class="fw700 c-blue f-16">Langkah01:</span>
                  <span class="f-16 c-000">
                    Masukkan nama pengguna Instagram yang ingin Anda jadikan story
                     unduh ke Savinginsta.App.</span
                  >
                </div>
              </div>
              <div class="step">
                <span class="fw700 c-blue f-16">Langkah02:</span>
                <span class="f-16 c-000">
                  Pilih Cerita yang ingin Anda unduh.</span
                >
              </div>
              <div class="step">
                <span class="fw700 c-blue f-16">Langkah03:</span>
                <span class="f-16 c-000"
                  >Klik 'Unduh' untuk menyimpan video Instagram Stories Anda
                   perangkat.</span
                >
              </div>
            </div>
          </div>
          <div class="features c-fff">
            <h3 class="h3 fw700 f-21">
              Bagaimana Cara Mengunduh Insta Story ke Ponsel Anda?
            </h3>
            <div class="attributes-list">
              <div class="features-title">
                Mengunduhnya sangat mudah. Berikut panduan lengkapnya:
              </div>
              <div class="item flex_">
                <div class="bgimg"></div>
                <div class="f-14 c-fff">
                  Buka Instagram di browser seperti Chrome, Firefox, atau
                   aplikasi Instagram.
                </div>
              </div>
              <div class="item flex_">
                <div class="bgimg"></div>
                <div class="f-14 c-fff">Pilih cerita yang menurut Anda menarik.</div>
              </div>
              <div class="item flex_">
                <div class="bgimg"></div>
                <div class="f-14 c-fff">
                  Klik pada video yang ingin Anda unduh.
                </div>
              </div>
              <div class="item flex_">
                <div class="bgimg"></div>
                <div class="f-14 c-fff">
                  Salin URL cerita dari bilah alamat.
                </div>
              </div>
              <div class="item flex_">
                <div class="bgimg"></div>
                <div class="f-14 c-fff">
                  Tempelkan nama pengguna ke kotak alamat di Savinginsta.
                </div>
              </div>
              <div class="item flex_">
                <div class="bgimg"></div>
                <div class="f-14 c-fff">
                  Tekan 'Unduh' untuk mengunduh kisah Instagram secara online.
                </div>
              </div>
              <div class="item flex_">
                <div class="bgimg"></div>
                <div class="f-14 c-fff">
                  Foto atau video IG story yang Anda unduh sekarang ada di folder Anda.
                </div>
              </div>
            </div>
          </div>
          <div class="how">
            <div class="how-title">
              <h3 class="f-36 c-000 italic">
                Bagaimana Cara Mengunduh Cerita dan Sorotan Instagram Secara Online?
              </h3>
            </div>
            <div class="steps">
              <div class="step">
                <div class="one">
                  <span class="f-16 c-000"
                    >Dapatkan tautan dari Instagram Stories atau salin
                     nama pengguna akun Instagram yang ingin Anda unduh
                     dari.</span
                  >
                </div>
              </div>
              <div class="step">
                <span class="f-16 c-000"
                  >Buka Savinginsta - Insta Story Downloader dan tempel
                   tautan cerita ke bilah alat.
                </span>
              </div>
              <div class="step">
                <span class="f-16 c-000"
                  >Pilih Cerita yang ditampilkan di layar, pilih cerita
                   yang ingin Anda unduh, lalu tekan 'Unduh'.</span
                >
              </div>
            </div>
          </div>
          <div class="quick-info">
            <h3 class="f-32 c-000">
              Apa yang Menjadikan Savinginsta.Com Unduhan Story Instagram (IG) Terbaik
               Alat?
            </h3>
            <ul class="f-16 c-ccc">
              <li>Alat yang mudah digunakan dan tercepat.</li>
              <li>Pembaruan terus-menerus untuk menawarkan layanan terbaik.</li>
              <li>
                Sepenuhnya GRATIS! Kami mendukung perkembangan kami melalui minimal
                 periklanan.
              </li>
            </ul>
          </div>
          <div class="faq-section">
            <h3 class="faq-title f-36 c-000 italic">FAQ</h3>
            <div class="accordion">
              <div
                id="faq"
                itemscope="itemscope"
                itemtype="https://schema.org/FAQPage"
              >
                <div
                  itemprop="mainEntity"
                  itemscope="itemscope"
                  itemtype="https://schema.org/Question"
                  class="accordion-item"
                  :key="k"
                  v-for="(item, k) in faqList"
                >
                  <h4 itemprop="name" class="accordion-title fw700 f-16">
                    {{ item.title }}
                  </h4>
                  <div
                    itemprop="acceptedAnswer"
                    itemscope=""
                    itemtype="https://schema.org/Answer"
                  >
                    <div
                      itemprop="text"
                      class="accordion-text f-16 c-ccc fw400"
                    >
                      {{ item.content }}
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <!-- 解析结果 start -->
      <div class="container" v-if="success">
        <success-content
          @refresh="refresh"
          :list="successList"
        ></success-content>
      </div>
      <!-- 解析结果 end -->
    </main>
    <footer>
      <div class="container">
        <div class="footer-content">
          <div class="footer-link">
            <div class="row flex_between">
              <div class="col-12">
                <div class="link-label fw700 c-000 f-21">Peralatan</div>
                <ul class="list-unstyled c-ccc f-16">
                  <li>
                    <nuxt-link to="/id/instagram-story-download"
                      >Pengunduh Cerita Instagram</nuxt-link
                    >
                  </li>
                  <li>
                    <nuxt-link to="/id/instagram-reels-video-download"
                      >Pengunduh Reel Instagram</nuxt-link
                    >
                  </li>
                  <li>
                    <a href="https://savingtik.com/" target="_blank"
                      >Pengunduh Tiktok</a
                    >
                  </li>
                </ul>
              </div>
              <div class="col-6">
                <div class="link-label fw700 c-000 f-21">Mendukung</div>
                <ul class="list-unstyled c-ccc f-16">
                  <li>
                    <nuxt-link to="/contact"> Kontak </nuxt-link>
                  </li>
                  <li>
                    <nuxt-link to="/blog"> Blog </nuxt-link>
                  </li>
                </ul>
              </div>
              <div class="col-6">
                <div class="link-label fw700 c-000 f-21">Hukum</div>
                <ul class="list-unstyled c-ccc f-16">
                  <li>
                    <nuxt-link to="/terms-of-service">
                      Ketentuan Layanan
                    </nuxt-link>
                  </li>
                  <li>
                    <nuxt-link to="/privacy-policy"> Kebijakan pribadi </nuxt-link>
                  </li>
                </ul>
              </div>
            </div>
          </div>
          <div class="copyright flex_ccenter">
            <b class="fw700 f-21 c-000"
              >Kami tidak berafiliasi dengan Instagram atau Meta</b
            >
            <div class="c-ccc f-16">
              © {{new Date().getFullYear()}} Insta Downloader All rights reserved.
            </div>
          </div>
        </div>
      </div>
    </footer>
  </div>
</template>
    
<script>
import { mapState, mapGetters, mapMutations } from "vuex";
import pageHeader from "~/components/page-header.vue";
import SuccessContent from "~/components/success-content.vue";
import CryptoJS from "crypto-js";
import { handleClick, checkString } from "@/plugins/Firebase.js";
export default {
  components: { pageHeader, SuccessContent },
  head: {
    htmlAttrs: {
      lang: "id",
    },
    bodyAttrs: {
      "data-lang": "id",
    },
    title: "Pengunduh Cerita Instagram Gratis Terbaik",
    meta: [
      { property: "og:locale", content: "id" },
      //Page Information
      {
        name: "description",
        content:
          "Unduh cerita Instagram online dengan mudah dengan Savinginsta Instagram Downloader gratis. Simpan cerita Instagram berkualitas tinggi langsung ke komputer atau ponsel Anda tanpa iklan apa pun. Tanpa tanda air",
      },

      //Schema.org Microdata
      {
        itemprop: "name",
        content: "Pengunduh Cerita Instagram Gratis Terbaik",
      },

      // Facebook / OpenGraph
      {
        property: "og:title",
        content: "Pengunduh Cerita Instagram Gratis Terbaik",
      },
      { property: "og:type", content: "website" },
      { property: "og:url", content: "https://savinginsta.com/id/instagram-story-download" },

      {
        property: "og:description",
        content:
          "Unduh cerita Instagram online dengan mudah dengan Savinginsta Instagram Downloader gratis. Simpan cerita Instagram berkualitas tinggi langsung ke komputer atau ponsel Anda tanpa iklan apa pun. Tanpa tanda air",
      },
      //Twitter
      { name: "twitter:card", content: "summary" },
      { name: "twitter:url", content: "https://savinginsta.com/id/instagram-story-download" },
      {
        name: "twitter:title",
        content: "Pengunduh Cerita Instagram Gratis Terbaik",
      },
      {
        name: "twitter:description",
        content:
          "Unduh cerita Instagram online dengan mudah dengan Savinginsta Instagram Downloader gratis. Simpan cerita Instagram berkualitas tinggi langsung ke komputer atau ponsel Anda tanpa iklan apa pun. Tanpa tanda air",
      },
      //multilingual
      {
        name: "google",
        content: "notranslate",
      },
    ],
    link: [
      //multilingual
      {
        rel: "alternate",
        hreflang: "x-default",
        href: "https://savinginsta.com/id/instagram-story-download",
      },
      {
        rel: "alternate",
        hreflang: "en",
        href: "https://savinginsta.com/instagram-story-download",
      },
      {
        rel: "alternate",
        hreflang: "en-in",
        href: "https://savinginsta.com/in/instagram-story-download",
      },
      {
        rel: "alternate",
        hreflang: "vi",
        href: "https://savinginsta.com/vn/instagram-story-download",
      },
      {
        rel: "alternate",
        hreflang: "tr",
        href: "https://savinginsta.com/tr/instagram-story-download",
      },
      {
        rel: "alternate",
        hreflang: "id",
        href: "https://savinginsta.com/id/instagram-story-download",
      },
      {
        rel: "alternate",
        hreflang: "fr",
        href: "https://savinginsta.com/fr/instagram-story-download",
      },
      {
        rel: "alternate",
        hreflang: "pt",
        href: "https://savinginsta.com/pt/instagram-story-download",
      },
      {
        rel: "alternate",
        hreflang: "ru",
        href: "https://savinginsta.com/ru/instagram-story-download",
      },
      {
        rel: "alternate",
        hreflang: "es",
        href: "https://savinginsta.com/es/instagram-story-download",
      },
      {
        rel: "alternate",
        hreflang: "ms",
        href: "https://savinginsta.com/ms/instagram-story-download",
      },
      {
        rel: "alternate",
        hreflang: "ko",
        href: "https://savinginsta.com/ko/instagram-story-download",
      },
      {
        rel: "alternate",
        hreflang: "ja",
        href: "https://savinginsta.com/ja/instagram-story-download",
      },
      {
        rel: "alternate",
        hreflang: "jv",
        href: "https://savinginsta.com/jv/instagram-story-download",
      },
      {
        rel: "alternate",
        hreflang: "cs",
        href: "https://savinginsta.com/cs/instagram-story-download",
      },
      {
        rel: "alternate",
        hreflang: "de",
        href: "https://savinginsta.com/de/instagram-story-download",
      },
      {
        rel: "alternate",
        hreflang: "it",
        href: "https://savinginsta.com/it/instagram-story-download",
      },
      {
        rel: "alternate",
        hreflang: "pl",
        href: "https://savinginsta.com/pl/instagram-story-download",
      },
      {
        rel: "alternate",
        hreflang: "hu",
        href: "https://savinginsta.com/hu/instagram-story-download",
      },
      {
        rel: "alternate",
        hreflang: "nl",
        href: "https://savinginsta.com/nl/instagram-story-download",
      },
      {
        rel: "alternate",
        hreflang: "ro",
        href: "https://savinginsta.com/ro/instagram-story-download",
      },
      {
        rel: "alternate",
        hreflang: "el",
        href: "https://savinginsta.com/el/instagram-story-download",
      },
      {
        rel: "canonical",
        href: "https://savinginsta.com/id/instagram-story-download",
      },
    ],
    script: [
      {
        json: {
          "@context": "http://schema.org",
          "@graph": [
            {
              "@type": "WebSite",
              name: "Savinginsta",
              alternateName: "Instagram downloader",
              url: "https://savinginsta.com",
            },
            {
              "@type": "WebPage",
              name: "Pengunduh Cerita Instagram Gratis Terbaik - Savinginsta", //title
              inLanguage: "id", //语种
              description:
                "Unduh cerita Instagram online dengan mudah dengan Savinginsta Instagram Downloader gratis. Simpan cerita Instagram berkualitas tinggi langsung ke komputer atau ponsel Anda tanpa iklan apa pun. Tanpa tanda air.", //元描述
              image: "https://savinginsta.com/static/images/savinginsta_thumbnail.jpg", //绝对路径
              url: "https://savinginsta.com/id/instagram-story-download", //当前url
            },
          ],
        },
        type: "application/ld+json",
      },
    ],
  },
  data() {
    return {
      input: "",
      success: false,
      isHttpLoading: false,
      httpError1: false,
      httpError2: false,
      current: 0,
      successList: [],
      faqList: [
        {
          title: `Apa itu Pengunduh Cerita Instagram?`,
          content: `Ini adalah alat gratis untuk mengunduh Instagram Stories dengan mudah tanpa registrasi.`,
        },
        {
          title: `Bagaimana Cara Mengunduh Video Kisah Instagram?`,
          content: `Ikuti instruksi sederhana di atas untuk mengunduh Instagram Stories dengan cepat di Savinginsta.`,
        },
        {
          title: `Bagaimana Saya Bisa Mengunduh Sorotan dari Instagram?`,
          content: `Untuk mengunduh highlight Instagram, akun harus bersifat publik. Masukkan nama pengguna di Savinginsta.app dan klik 'Unduh'.`,
        },
        {
          title: `Bagaimana jika Saya Ingin Melihat IG Stories Secara Anonim?`,
          content: `Kami memiliki solusi sempurna: penampil Cerita Instagram anonim kami, Penampil Cerita Instagram.`,
        },
        {
          title: `Apakah Anda Perlu Masuk dengan Akun Instagram Anda?`,
          content: `Tidak perlu masuk. Savinginsta tidak meminta informasi pribadi apa pun, memastikan unduhan aman dan anonim.`,
        },
        {
          title: `Bisakah Saya Menyimpan Video Langsung di Instagram?`,
          content: `Ya, tapi Anda harus menunggu sampai videonya berakhir.`,
        },
        {
          title: `Apakah Situs Web Mendukung Pengunduhan dari Insta untuk Komputer?`,
          content: `Tentu saja, Anda dapat mengunduh video, foto, cerita, dan lainnya dari PC. Lihat juga: Unduh dari Insta di PC.`,
        },
        {
          title: `Bisakah Anda Mengunduh Cerita Instagram untuk Android?`,
          content: `Ya, copy link postingannya, paste ke kotak website kita, lalu simpan. Untuk info lebih lanjut: Unduh dari Insta di Android.`,
        },
        {
          title: `Cara Download Video dan Foto Story Instagram di iPhone?`,
          content: `Ini semudah di Android. Lihat panduan Mengunduh cerita Instagram untuk iOS.`,
        },
        {
          title: `Di Mana Saya Dapat Menemukan Video Cerita Tersimpan di Komputer?`,
          content: `Periksa riwayat unduhan browser Anda menggunakan Ctrl+J untuk Windows dan Shift+Command+J untuk Mac.`,
        },
      ],
    };
  },
  computed: {
    ...mapGetters(["language"]),
  },
  mounted() {
    this.debouncedDownInput = this.debounce(this.downInput, 1000);
  },
  methods: {
    async downloadHandel() {
      if (this.isHttpLoading || this.input === "") return;
      this.isHttpLoading = false;
      this.httpError1 = false;
      this.httpError2 = false;
      this.input = this.input.replace(/^.*\s?https:\/\//, "https://");
      const insUrlPattern = new RegExp("^http(s|)://.*instagram.com.*/.*$");
      let type = checkString(this.input);
      if (!insUrlPattern.test(this.input)) {
        //点击解析下载按钮
        handleClick("action_ins_detect_boinsom", {
          site: "other",
          noislink: this.input,
          from: "story",
          type: type,
        });
        this.httpError2 = true;
        this.isHttpLoading = false;
        return;
      }
      //点击解析下载按钮
      handleClick("action_ins_detect_boinsom", {
        site: "other",
        from: "story",
        type: type,
      });
      //开始解析  ins_start_resolve
      handleClick("ins_start_resolve", {
        islink: this.input,
        from: "story",
        type: type,
      });
      this.isHttpLoading = true;
      try {
        let result = this.uki(this.input);
        const response = await fetch(
          "https://savinginsta.com/api/downloader/analysis",
          {
            method: "POST",
            headers: { "Content-Type": "application/json" },
            body: JSON.stringify({
              path: result,
            }),
          }
        );
        let encryptedResponse = await response.text();
        let parse = JSON.parse(encryptedResponse);
        if (parse.code != 200) {
          // 解析失败  ins_resolve_fail
          handleClick("ins_resolve_fail", {
            reason: "Failed to fetch",
            islink: this.input,
            from: "story",
            type: type,
          });
          this.httpError1 = true;
          this.isHttpLoading = false;
          return;
        } else {
          //解析成功  ins_resolve_success
          handleClick("ins_resolve_success", {
            type: type,
            from: "story",
          });
          let decryptedResponse = await this.eki(parse.data); // 使用你的解密函数
          this.successList = JSON.parse(decryptedResponse);
          this.success = true;
          this.isHttpLoading = false;
        }
      } catch (error) {
        // 解析失败  ins_resolve_fail
        handleClick("ins_resolve_fail", {
          reason: "Failed to fetch",
          islink: this.input,
          from: "story",
          type: type,
        });
        console.error(error);
        this.httpError1 = true;
        this.isHttpLoading = false;
      }
    },

    uki(input) {
      let CIPHER_ALGORITHM = "DES-CBC";
      let IV_SIZE = 8;
       
      
  try {
        const complexKey = [
          process.env.part1,
          process.env.part2,
          process.env.part3,
          process.env.part4,
          process.env.part5,
          process.env.part6,
          process.env.part7,
          process.env.part8,
        ].join("");
        const keyBytes = CryptoJS.enc.Utf8.parse(complexKey);
        const inputBytes = CryptoJS.enc.Utf8.parse(input);
        const ivBytes = CryptoJS.lib.WordArray.random(IV_SIZE);
        const encrypted = CryptoJS.DES.encrypt(inputBytes, keyBytes, {
          iv: ivBytes,
          mode: CryptoJS.mode.CBC,
          padding: CryptoJS.pad.Pkcs7,
        });
        const ciphertext = ivBytes.concat(encrypted.ciphertext);
        return ciphertext.toString();
      } catch (error) {
        console.error(error);
        return null;
      }
    },
    eki(cipherText) {
      let CIPHER_ALGORITHM = "DES-CBC";
      let IV_SIZE = 8;
       
      const complexKey = [
          process.env.part1,
          process.env.part2,
          process.env.part3,
          process.env.part4,
          process.env.part5,
          process.env.part6,
          process.env.part7,
          process.env.part8,
        ].join("");
      try {
        let keyBytes = CryptoJS.enc.Utf8.parse(
          complexKey.padEnd(CIPHER_ALGORITHM === "DES-CBC" ? 8 : 16)
        );
        let ivBytes = { iv: CryptoJS.enc.Hex.parse(process.env.DES_IV) }; // 如果使用CBC模式，需要一个初始化向量iv，这里是空向量
        let decrypted = CryptoJS.DES.decrypt(
          { ciphertext: CryptoJS.enc.Hex.parse(cipherText) },
          keyBytes,
          ivBytes
        );
        return decrypted.toString(CryptoJS.enc.Utf8);
      } catch (e) {
        console.error(e);
        return null;
      }
    },
    sendDownload(event) {
      if (event.keyCode === 13 && !this.isHttpLoading) {
        this.downloadHandel();
        event.preventDefault();
        return false;
      }
    },
    changeTab(k) {
      this.current = k;
    },
    handleInput(e) {
      this.debouncedDownInput(e);
    },
    debounce(fn, delay) {
      let timer;
      return function () {
        let context = this;
        let args = arguments;
        clearTimeout(timer);
        timer = setTimeout(() => {
          fn.apply(context, args);
        }, delay);
      };
    },
    downInput(e) {
      let type = checkString(e.target.value);
      // 粘贴链接到输入框 action_ins_paste
      handleClick("action_ins_paste", {
        islink: e.target.value,
        from: "story",
        type: type,
      });
    },
    handleClickPasted() {
      if (!navigator.clipboard) {
        console.log("Clipboard API not available");
        return;
      }
      navigator.clipboard
        .readText()
        .then((text) => {
          this.input = text;
          let type = checkString(text);
          // 粘贴链接到输入框 action_ins_paste
          handleClick("action_ins_paste", {
            islink: text,
            from: "story",
            type: type,
          });
        })
        .catch((err) => {
          console.error("Failed to read clipboard contents: ", err);
        });
    },
    showLanguageHandel() {
      this.$refs.languageRef.close();
    },
    refresh() {
      this.success = false;
      this.input = "";
      this.successList = [];
    },
  },
};
</script>
<style lang="scss" scoped>
@import "@/static/style/story.css";
.loading {
  .loading-dots {
    position: relative;
    z-index: 999;
    margin-top: 70px;
  }

  .dot {
    background-color: #ffffff;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin: 0 10px;
    animation: loading-animation 1.5s infinite;
  }

  .dot:nth-child(2) {
    animation-delay: 0.5s;
  }

  .dot:nth-child(3) {
    animation-delay: 0.8s;
  }
  .dot:nth-child(4) {
    animation-delay: 1s;
  }
}
@keyframes loading-animation {
  0%,
  50%,
  80%,
  100% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.5);
  }
}
@media (max-width: 768px) {
  .loading {
    .loading-dots {
      margin-top: 26px !important;
    }
    .dot {
      width: 8px !important;
      height: 8px !important;
    }
  }
}
</style>
    